import React, { Component } from 'react';
import { RouteLayout } from 'weaver-mobile-page';
import { Tools } from 'weaver-mobile';
import { TitleUtil } from '../../util';

export default class ViewHtml extends Component {
  componentDidMount() {
    const { title } = this.props;
    TitleUtil.setTitle(title);
    if(Tools.mobileDetect().is("iPhone") && window.iNoBounce && window.iNoBounce.isEnabled()) {
      window.iNoBounce.disable(); // 解决ios滑动问题
    }
  }

  componentWillUnmount() {
    TitleUtil.resetEmElement();
    if(Tools.mobileDetect().is("iPhone") && window.iNoBounce && window.iNoBounce.isEnabled()) {
      window.iNoBounce.enable(); // 解决ios滑动问题
    }
  }

  render() {
    const { html } = this.props;
    return (
      <RouteLayout>
        <div key="templateView" className="wm-route-layout" >
          <div className="mail-template-container">
            <div className="mail-template-html" dangerouslySetInnerHTML={{ __html: html }} />
          </div>
        </div>
      </RouteLayout>
    );
  }
}
